home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.awt;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.Panel;
- import java.awt.Rectangle;
- import java.awt.Scrollbar;
- import java.awt.image.MemoryImageSource;
- import java.util.Vector;
-
- public class ImageListBox extends Panel {
- public static final int EVT_IMAGE_SELECT = 16388;
- public static final int BORDER_REGULAR = 0;
- public static final int BORDER_NONE = 1;
- public static final int IMAGE_WIDTH = 19;
- private final int LINE_SLOP;
- protected int nTopRow;
- protected int lWidth;
- protected int cellHt;
- protected int yAdj;
- protected int borderWidth;
- protected int halfBorderWidth;
- private Component ilbParent;
- private String ilbLabel;
- private Image SelectImage;
- private Scrollbar VBar;
- private Scrollbar HBar;
- private Vector items;
- private Font font;
- // $FF: renamed from: fm java.awt.FontMetrics
- private FontMetrics field_0;
- private boolean bAllDirty;
- private boolean bMultipleSelections;
- private boolean bBlockPaint;
- private boolean bVBarVisible;
- private boolean bHBarVisible;
- private boolean bInternalBlockPaint;
- private int rowsToShow;
- private int colsToShow;
- private int visibleRows;
- private int visibleCols;
- private int visibleIndex;
- private int fontHeight;
- private int fontDescent;
- private int lastDownModifiers;
- private int lastSelected;
- private int lastIndex;
- private int lastTempIndex;
- private int countSelected;
- private int borderType;
- private int longestLineValue;
- private int barSize;
- private int xCoord;
- private long prevSelectTime;
- private long prevSelectRow;
- private boolean bOsFlag;
- private boolean bComboMode;
- private boolean bCellBorders;
- private boolean bAllowShowVBar;
- private boolean bAllowShowHBar;
- private Color enabledColor;
- private Color disabledColor;
- private int fastDownCount;
- private boolean bMouseDrawHandled;
- private boolean bClipRectHack;
- private boolean bDirectNotify;
-
- public ImageListBox() {
- this((Component)null, "", -1, false);
- }
-
- public ImageListBox(String var1) {
- this((Component)null, var1, -1, false);
- }
-
- public ImageListBox(String var1, boolean var2) {
- this((Component)null, var1, -1, var2);
- }
-
- public ImageListBox(String var1, int var2, boolean var3) {
- this((Component)null, var1, var2, var3);
- }
-
- public ImageListBox(Component var1, String var2) {
- this(var1, var2, -1, false);
- }
-
- public ImageListBox(Component var1, String var2, int var3, boolean var4) {
- this.LINE_SLOP = 6;
- this.yAdj = 6;
- this.borderWidth = 4;
- this.halfBorderWidth = 2;
- this.bAllDirty = true;
- this.bMultipleSelections = false;
- this.bBlockPaint = false;
- this.bVBarVisible = false;
- this.bHBarVisible = false;
- this.bInternalBlockPaint = false;
- this.rowsToShow = -1;
- this.colsToShow = 10;
- this.visibleRows = -1;
- this.visibleCols = -1;
- this.visibleIndex = -1;
- this.lastDownModifiers = -1;
- this.lastSelected = -1;
- this.lastIndex = -1;
- this.lastTempIndex = -1;
- this.barSize = 15;
- this.prevSelectTime = -1L;
- this.prevSelectRow = -1L;
- this.bComboMode = false;
- this.bCellBorders = false;
- this.bAllowShowVBar = true;
- this.bAllowShowHBar = true;
- this.enabledColor = Color.black;
- this.disabledColor = Color.gray;
- this.bMouseDrawHandled = false;
- this.bClipRectHack = false;
- this.bDirectNotify = true;
- if (!System.getProperty("os.name").startsWith("S")) {
- this.bOsFlag = false;
- this.barSize = 15;
- } else {
- this.bOsFlag = true;
- this.barSize = 17;
- }
-
- this.items = new Vector();
- this.ilbParent = var1;
- this.ilbLabel = var2;
- this.rowsToShow = var3;
- this.bMultipleSelections = var4;
- byte var5 = 20;
- byte var6 = 20;
- int[] var7 = new int[var5 * var6];
- int var8 = 0;
-
- for(int var9 = 0; var9 < var6; ++var9) {
- for(int var10 = 0; var10 < var5; ++var10) {
- var7[var8++] = -16777088;
- }
- }
-
- this.SelectImage = ((Component)this).createImage(new MemoryImageSource(var5, var6, var7, 0, var5));
- ((Container)this).setLayout((LayoutManager)null);
- ((Component)this).setBackground(Color.white);
- this.VBar = new Scrollbar();
- this.VBar.setBackground(Color.lightGray);
- ((Container)this).add(this.VBar);
- this.HBar = new Scrollbar(0);
- this.HBar.setBackground(Color.lightGray);
- ((Container)this).add(this.HBar);
- this.setFont(new Font("Helvetica", 0, 12));
- }
-
- public void setComboMode(boolean var1) {
- this.bComboMode = var1;
- this.yAdj = 6;
- ((Component)this).invalidate();
- }
-
- public boolean getComboMode() {
- return this.bComboMode;
- }
-
- public void setRowsToShow(int var1) {
- this.rowsToShow = var1;
- ((Component)this).invalidate();
- }
-
- public int getRowsToShow() {
- return this.rowsToShow;
- }
-
- public void setShowVerticalScroll(boolean var1) {
- if (this.bAllowShowVBar != var1) {
- this.bAllowShowVBar = var1;
- ((Component)this).invalidate();
- }
-
- }
-
- public boolean getShowVerticalScroll() {
- return this.bAllowShowVBar;
- }
-
- public void setShowHorizontalScroll(boolean var1) {
- if (this.bAllowShowHBar != var1) {
- this.bAllowShowHBar = var1;
- ((Component)this).invalidate();
- }
-
- }
-
- public boolean getShowHorizontalScroll() {
- return this.bAllowShowHBar;
- }
-
- public void setBorderType(int var1) {
- this.borderType = var1;
- if (var1 == 0) {
- this.borderWidth = 4;
- this.halfBorderWidth = 2;
- } else {
- this.borderWidth = 0;
- this.halfBorderWidth = 0;
- }
-
- ((Component)this).invalidate();
- }
-
- public int getBorderType() {
- return this.borderType;
- }
-
- public void setCellBorder(int var1, boolean var2) {
- if (this.validIndex(var1)) {
- ListItem var3 = (ListItem)this.items.elementAt(var1);
- if (var3.bCellBorder != var2) {
- var3.bCellBorder = var2;
- var3.bDirty = true;
- ((Component)this).invalidate();
- }
- }
-
- }
-
- public void setCellBorders(boolean var1) {
- this.bCellBorders = var1;
- int var2 = this.items.size();
- Object var3 = null;
-
- for(int var4 = 0; var4 < var2; ++var4) {
- ListItem var5 = (ListItem)this.items.elementAt(var4);
- var5.bCellBorder = var1;
- }
-
- this.bAllDirty = true;
- ((Component)this).invalidate();
- }
-
- public boolean getCellBorders() {
- return this.bCellBorders;
- }
-
- public void setDefaultEnabledTextColor(Color var1) {
- this.enabledColor = var1;
- ((Component)this).invalidate();
- }
-
- public Color getDefaultEnabledTextColor() {
- return this.enabledColor;
- }
-
- public void setDisabledTextColor(Color var1) {
- this.disabledColor = var1;
- ((Component)this).invalidate();
- }
-
- public Color getDisabledTextColor() {
- return this.disabledColor;
- }
-
- public void setEnabledTextColor(int var1, Color var2) {
- if (this.validIndex(var1)) {
- ListItem var3 = (ListItem)this.items.elementAt(var1);
- var3.color = var2;
- }
-
- }
-
- public boolean handleEvent(Event var1) {
- int var5 = -1;
- switch (var1.id) {
- case 403:
- if (var1.modifiers <= 1) {
- switch (var1.key) {
- case 1000:
- var5 = this.keyCalcIndex(0, true);
- break;
- case 1001:
- var5 = this.keyCalcIndex(this.items.size() - 1, true);
- break;
- case 1002:
- var5 = this.keyCalcIndex(-this.visibleRows, false);
- break;
- case 1003:
- var5 = this.keyCalcIndex(this.visibleRows, false);
- break;
- case 1004:
- var5 = this.keyCalcIndex(-1, false);
- break;
- case 1005:
- var5 = this.keyCalcIndex(1, false);
- }
-
- if (var5 != -1) {
- if (this.bMultipleSelections) {
- switch (var1.modifiers) {
- case 0:
- break;
- case 1:
- this.makeVisible(var5);
- this.shiftSelect(var5, false);
- return true;
- default:
- return true;
- }
- }
-
- this.select(var5);
- ((Component)this).repaint();
- var1.x = -1;
- this.notifyParent(var1, var5, false);
- this.prevSelectTime = -1L;
- this.prevSelectRow = -1L;
- return true;
- }
- }
- break;
- case 501:
- ++this.fastDownCount;
- this.bMouseDrawHandled = false;
- this.lastDownModifiers = var1.modifiers;
- if (var1.x > -1 && var1.x < this.lWidth) {
- var5 = this.mouseCalcIndex(var1.y);
- if (var5 == -1) {
- return true;
- }
-
- if (this.bMultipleSelections) {
- switch (this.lastDownModifiers) {
- case 1:
- this.bMouseDrawHandled = true;
- this.shiftSelect(var5, false);
- break;
- case 2:
- this.bMouseDrawHandled = true;
- this.ctrlSelect(var5);
- break;
- case 3:
- this.bMouseDrawHandled = true;
- this.shiftSelect(var5, true);
- break;
- default:
- this.select(var5);
- }
-
- ((Component)this).repaint();
- } else {
- this.lastTempIndex = var5;
- if (this.lastSelected == var5) {
- return true;
- }
-
- this.select(var5);
- ((Component)this).repaint();
- }
- }
-
- return true;
- case 502:
- --this.fastDownCount;
- if (this.bMouseDrawHandled) {
- var1.x = -1;
- this.notifyParent(var1, -1, false);
- return true;
- }
-
- if (!this.bMultipleSelections) {
- var5 = this.mouseCalcIndex(var1.y);
- if (var5 == -1 || var1.x < 0 || var1.x >= this.lWidth) {
- this.fastDownCount = 0;
- var5 = this.lastTempIndex;
- if (var5 == -1) {
- return true;
- }
- }
- }
-
- boolean var4;
- if (this.bComboMode) {
- this.fastDownCount = 0;
- var4 = false;
- } else if (this.fastDownCount > 0) {
- this.fastDownCount = 0;
- var4 = true;
- this.prevSelectTime = -1L;
- this.prevSelectRow = -1L;
- } else {
- long var2 = System.currentTimeMillis();
- if (this.prevSelectTime != -1L && this.prevSelectRow == (long)var5 && this.prevSelectTime + 250L > var2) {
- var4 = true;
- this.prevSelectTime = -1L;
- this.prevSelectRow = -1L;
- } else {
- var4 = false;
- this.prevSelectTime = var2;
- this.prevSelectRow = (long)var5;
- }
- }
-
- if (this.lastSelected != var5) {
- this.select(var5);
- ((Component)this).repaint();
- }
-
- if (this.bMultipleSelections) {
- this.notifyParent(var1, this.lastSelected, var4);
- this.lastIndex = this.lastSelected;
- } else {
- this.notifyParent(var1, var5, var4);
- this.lastIndex = var5;
- }
-
- this.lastTempIndex = -1;
- this.lastDownModifiers = -1;
- return true;
- case 503:
- if (this.bMultipleSelections) {
- break;
- }
- case 506:
- if (var1.x > -1 && var1.x < this.lWidth) {
- if (this.bComboMode) {
- var5 = this.mouseCalcIndex(var1.y);
- if (var5 == -1 || var5 == this.lastIndex) {
- return true;
- }
-
- this.lastIndex = var5;
- this.select(var5);
- ((Component)this).repaint();
- } else if (var1.id == 506) {
- var5 = this.mouseCalcIndex(var1.y);
- if (var5 != -1 && var5 != this.lastIndex) {
- if (this.bMultipleSelections) {
- if (this.lastDownModifiers != 0) {
- return false;
- }
-
- this.bInternalBlockPaint = true;
- this.makeVisible(var5);
- this.bInternalBlockPaint = false;
- this.shiftSelect(var5, false);
- } else {
- this.select(var5);
- }
-
- this.lastIndex = var5;
- }
- }
- }
- break;
- case 505:
- if (!this.bMultipleSelections && this.bComboMode) {
- this.lastIndex = -1;
- }
- break;
- case 601:
- if (var1.target == this.VBar) {
- this.scrollVertical(var1.id, false);
- } else {
- this.scrollHorizontal(var1.id, false);
- }
- break;
- case 602:
- if (var1.target == this.VBar) {
- this.scrollVertical(var1.id, false);
- } else {
- this.scrollHorizontal(var1.id, false);
- }
- break;
- case 603:
- if (var1.target == this.VBar) {
- this.scrollVertical(var1.id, false);
- } else {
- this.scrollHorizontal(var1.id, false);
- }
- break;
- case 604:
- if (var1.target == this.VBar) {
- this.scrollVertical(var1.id, false);
- } else {
- this.scrollHorizontal(var1.id, false);
- }
- break;
- case 605:
- if (var1.target == this.VBar) {
- this.scrollVertical((Integer)var1.arg, true);
- } else {
- this.scrollHorizontal((Integer)var1.arg, true);
- }
- }
-
- return false;
- }
-
- public synchronized void setMultiColumnMode(boolean var1) {
- this.bComboMode = false;
- this.yAdj = 2;
- this.setBorderType(1);
- this.setCellBorders(var1);
- }
-
- public synchronized void addItem(String var1) {
- this.addItem(new ListItem((Image)null, var1, true, this.field_0, this.bCellBorders));
- }
-
- public void setListItems(String[] var1) {
- this.clear();
-
- for(int var2 = 0; var2 < var1.length; ++var2) {
- this.addItem(var1[var2]);
- }
-
- }
-
- public String[] getListItems() {
- int var1 = this.countItems();
- String[] var2 = new String[var1];
-
- for(int var3 = 0; var3 < var1; ++var3) {
- var2[var3] = this.getItem(var3);
- }
-
- return var2;
- }
-
- public synchronized void addItem(String var1, boolean var2) {
- this.addItem(new ListItem((Image)null, var1, var2, this.field_0, this.bCellBorders));
- }
-
- public synchronized void addItem(Image var1, String var2) {
- this.addItem(new ListItem(var1, var2, true, this.field_0, this.bCellBorders));
- }
-
- public synchronized void addItem(Image var1, String var2, boolean var3) {
- this.addItem(new ListItem(var1, var2, var3, this.field_0, this.bCellBorders));
- }
-
- public synchronized void addItem(Image var1, String var2, boolean var3, Color var4) {
- ListItem var5 = new ListItem(var1, var2, var3, this.field_0, this.bCellBorders);
- var5.color = var4;
- this.addItem(var5);
- }
-
- private void addItem(ListItem var1) {
- this.items.addElement(var1);
- this.updateWidth(var1);
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
-
- }
-
- public synchronized void insertItem(int var1, Image var2, String var3, boolean var4) {
- Object var5 = null;
- ListItem var6;
- if (this.validIndex(var1)) {
- this.items.insertElementAt(var6 = new ListItem(var2, var3, var4, this.field_0, this.bCellBorders), var1);
- this.bAllDirty = true;
- if (this.lastSelected >= var1) {
- ++this.lastSelected;
- }
- } else {
- this.items.addElement(var6 = new ListItem(var2, var3, var4, this.field_0, this.bCellBorders));
- }
-
- this.updateWidth(var6);
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
-
- }
-
- public synchronized void insertItems(int var1, Vector var2, Image var3, boolean var4) {
- int var5 = var2.size();
- boolean var6 = false;
- if (this.validIndex(var1)) {
- for(int var7 = 0; var7 < var5; ++var7) {
- this.items.insertElementAt(new ListItem(var3, (String)var2.elementAt(var7), var4, this.field_0, this.bCellBorders), var1++);
- }
- } else {
- for(int var8 = 0; var8 < var5; ++var8) {
- this.items.addElement(new ListItem(var3, (String)var2.elementAt(var8), var4, this.field_0, this.bCellBorders));
- }
- }
-
- this.deselectAll();
- this.bAllDirty = true;
- this.updateWidths(this.field_0);
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
-
- }
-
- public int countItems() {
- return this.items.size();
- }
-
- public String getItem(int var1) {
- return this.validIndex(var1) ? ((ListItem)this.items.elementAt(var1)).sText : null;
- }
-
- public Image getImage(int var1) {
- return this.validIndex(var1) ? ((ListItem)this.items.elementAt(var1)).image : null;
- }
-
- public void changeImage(int var1, Image var2) {
- if (this.validIndex(var1)) {
- ListItem var3 = (ListItem)this.items.elementAt(var1);
- var3.image = var2;
- var3.bDirty = true;
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
- }
-
- }
-
- public void changeText(int var1, String var2) {
- if (this.validIndex(var1)) {
- ListItem var3 = (ListItem)this.items.elementAt(var1);
- var3.sText = var2;
- var3.bDirty = true;
- var3.updateWidth(this.field_0);
- this.updateWidth(var3);
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
- }
-
- }
-
- public void setEdited(int var1, boolean var2) {
- if (this.validIndex(var1)) {
- ListItem var3 = (ListItem)this.items.elementAt(var1);
- var3.bEdited = var2;
- }
-
- }
-
- public boolean getEdited(int var1) {
- if (this.validIndex(var1)) {
- ListItem var2 = (ListItem)this.items.elementAt(var1);
- return var2.bEdited;
- } else {
- return false;
- }
- }
-
- public void enable(int var1) {
- if (this.validIndex(var1)) {
- ListItem var2 = (ListItem)this.items.elementAt(var1);
- if (!var2.bEnabled) {
- var2.bEnabled = true;
- var2.bDirty = true;
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
- }
- }
-
- }
-
- public void disable(int var1) {
- if (this.validIndex(var1)) {
- ListItem var2 = (ListItem)this.items.elementAt(var1);
- if (var2.bEnabled) {
- var2.bEnabled = false;
- var2.bDirty = true;
- this.deselect(var1);
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
- }
- }
-
- }
-
- public void enable(int var1, boolean var2) {
- if (var2) {
- this.enable(var1);
- } else {
- this.disable(var1);
- }
- }
-
- public boolean isEnabled(int var1) {
- if (this.validIndex(var1)) {
- ListItem var2 = (ListItem)this.items.elementAt(var1);
- return var2.bEnabled;
- } else {
- return false;
- }
- }
-
- public synchronized void clear() {
- this.items = new Vector();
- this.nTopRow = 0;
- this.visibleIndex = -1;
- this.lastDownModifiers = -1;
- this.lastSelected = -1;
- this.lastIndex = -1;
- this.lastTempIndex = -1;
- this.countSelected = 0;
- this.prevSelectTime = -1L;
- this.prevSelectRow = -1L;
- this.VBar.setValues(1, 1, 0, 2);
- this.VBar.hide();
- this.bVBarVisible = false;
- this.HBar.setValues(1, 1, 0, 2);
- this.HBar.hide();
- this.bHBarVisible = false;
- this.bAllDirty = true;
- this.bInternalBlockPaint = false;
- this.bBlockPaint = false;
- this.longestLineValue = 0;
- this.xCoord = 0;
- ((Component)this).repaint();
- }
-
- public synchronized void delItem(int var1) {
- if (this.validIndex(var1)) {
- this.deselect(var1);
- this.items.removeElementAt(var1);
- this.bAllDirty = true;
- this.scrollVertical(this.nTopRow, true);
- this.updateWidths((FontMetrics)null);
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
- }
-
- }
-
- public synchronized void delItems(int var1, int var2) {
- int var3 = this.items.size();
- if (var3 > 0) {
- if (var2 >= var3) {
- var2 = var3 - 1;
- }
-
- if (var1 < 0) {
- var1 = 0;
- }
-
- if (var1 <= var2) {
- this.bInternalBlockPaint = true;
-
- for(int var4 = var2; var4 >= var1; --var4) {
- this.deselect(var4);
- this.items.removeElementAt(var4);
- }
-
- this.bInternalBlockPaint = false;
- this.bAllDirty = true;
- this.scrollVertical(this.nTopRow, true);
- this.updateWidths((FontMetrics)null);
- ((Component)this).repaint();
- }
- }
-
- }
-
- public synchronized void delSelectedItems() {
- int var1 = this.items.size();
- this.bInternalBlockPaint = true;
- int var2 = 0;
-
- while(var2 < var1) {
- ListItem var3 = (ListItem)this.items.elementAt(var2);
- if (var3.bSelected) {
- this.deselect(var2);
- this.items.removeElementAt(var2);
- --var1;
- } else {
- ++var2;
- }
- }
-
- this.bAllDirty = true;
- this.scrollVertical(this.nTopRow, true);
- this.updateWidths((FontMetrics)null);
- this.bInternalBlockPaint = false;
- ((Component)this).repaint();
- }
-
- public synchronized int getSelectedIndex() {
- return this.lastSelected;
- }
-
- public synchronized int[] getSelectedIndexes() {
- int[] var1 = new int[this.countSelected];
- if (this.countSelected == 1) {
- var1[0] = this.lastSelected;
- } else if (this.countSelected > 1) {
- int var2 = 0;
- int var3 = this.items.size();
-
- for(int var4 = 0; var4 < var3; ++var4) {
- ListItem var5 = (ListItem)this.items.elementAt(var4);
- if (var5.bSelected) {
- var1[var2++] = var4;
- if (var2 == this.countSelected) {
- break;
- }
- }
- }
- }
-
- return var1;
- }
-
- public synchronized String getSelectedItem() {
- return this.lastSelected < 0 ? null : this.getItem(this.lastSelected);
- }
-
- public synchronized String[] getSelectedItems() {
- String[] var1 = new String[this.countSelected];
- if (!this.bMultipleSelections) {
- if (this.lastSelected != -1) {
- ListItem var2 = (ListItem)this.items.elementAt(this.lastSelected);
- var1[0] = var2.sText;
- }
- } else if (this.countSelected > 0) {
- int var3 = 0;
- int var4 = this.items.size();
-
- for(int var5 = 0; var5 < var4; ++var5) {
- ListItem var6 = (ListItem)this.items.elementAt(var5);
- if (var6.bSelected) {
- var1[var3] = var6.sText;
- ++var3;
- if (var3 == this.countSelected) {
- break;
- }
- }
- }
- }
-
- return var1;
- }
-
- public synchronized String getLabel() {
- return new String(this.ilbLabel);
- }
-
- public synchronized void select(int var1) {
- if (this.isEnabled(var1)) {
- Object var2 = null;
- if (this.bMultipleSelections) {
- int var3 = this.items.size();
-
- for(int var4 = 0; var4 < var3; ++var4) {
- ListItem var6 = (ListItem)this.items.elementAt(var4);
- if (var4 == var1) {
- if (!var6.bSelected) {
- var6.bSelected = true;
- var6.bDirty = true;
- }
- } else if (var6.bSelected) {
- var6.bSelected = false;
- var6.bDirty = true;
- }
- }
- } else if (this.lastSelected != var1) {
- if (this.lastSelected != -1) {
- this.deselect(this.lastSelected);
- }
-
- ListItem var5 = (ListItem)this.items.elementAt(var1);
- var5.bSelected = true;
- var5.bDirty = true;
- }
-
- this.lastSelected = var1;
- this.countSelected = 1;
- this.makeVisible(var1);
- }
-
- }
-
- public synchronized void select(String var1) {
- int var3 = this.items.size();
-
- for(int var4 = 0; var4 < var3; ++var4) {
- ListItem var2 = (ListItem)this.items.elementAt(var4);
- if (var2.sText.equals(var1)) {
- if (var2.bEnabled) {
- this.select(var4);
- }
-
- return;
- }
- }
-
- }
-
- public synchronized void selectMultiple(int var1, boolean var2, boolean var3) {
- if (!this.bMultipleSelections) {
- var2 = false;
- var3 = false;
- }
-
- if (var2) {
- this.shiftSelect(var1, var3);
- } else if (var3) {
- this.ctrlSelect(var1);
- } else {
- this.select(var1);
- }
- }
-
- public synchronized void selectAll() {
- if (this.bMultipleSelections) {
- int var1 = this.items.size();
-
- for(int var3 = 0; var3 < var1; ++var3) {
- ListItem var2 = (ListItem)this.items.elementAt(var3);
- if (var2.bEnabled) {
- var2.bSelected = true;
- }
- }
-
- this.countSelected = var1;
- this.lastSelected = var1 - 1;
- ((Component)this).repaint();
- }
- }
-
- public synchronized void deselect(int var1) {
- if (this.validIndex(var1)) {
- ListItem var2 = (ListItem)this.items.elementAt(var1);
- if (var2.bSelected) {
- if (this.lastSelected == var1) {
- this.lastSelected = -1;
- }
-
- var2.bSelected = false;
- var2.bDirty = true;
- --this.countSelected;
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
- }
- }
-
- }
-
- public synchronized void deselectAll() {
- if (!this.bMultipleSelections) {
- if (this.lastSelected != -1) {
- ListItem var1 = (ListItem)this.items.elementAt(this.lastSelected);
- var1.bSelected = false;
- var1.bDirty = true;
- }
- } else {
- int var2 = this.items.size();
-
- for(int var3 = 0; var3 < var2; ++var3) {
- ListItem var4 = (ListItem)this.items.elementAt(var3);
- if (var4.bSelected) {
- var4.bSelected = false;
- var4.bDirty = true;
- }
- }
- }
-
- this.lastSelected = -1;
- this.countSelected = 0;
- ((Component)this).repaint();
- }
-
- public synchronized boolean isSelected(int var1) {
- if (this.validIndex(var1)) {
- ListItem var2 = (ListItem)this.items.elementAt(var1);
- return var2.bSelected;
- } else {
- return false;
- }
- }
-
- public int getRows() {
- return this.visibleRows;
- }
-
- public boolean allowsMultipleSelections() {
- return this.bMultipleSelections;
- }
-
- public void setMultipleSelections(boolean var1) {
- if (var1 != this.bMultipleSelections) {
- if (!var1) {
- this.deselectAll();
- }
-
- this.bMultipleSelections = var1;
- }
-
- }
-
- public int getVisibleIndex() {
- return this.visibleIndex;
- }
-
- public synchronized void makeVisible(int var1) {
- this.visibleIndex = var1;
- if (this.nTopRow > var1) {
- this.scrollVertical(var1, true);
- } else {
- if (var1 >= this.nTopRow + this.visibleRows) {
- this.scrollVertical(var1 - this.visibleRows + 1, true);
- }
-
- }
- }
-
- public void setTopRow(int var1) {
- int var2 = this.items.size();
- if (var2 < this.visibleRows) {
- var1 = 0;
- } else if (var1 > var2 - this.visibleRows) {
- var1 = var2 - this.visibleRows;
- }
-
- if (this.nTopRow != var1) {
- this.nTopRow = var1;
- this.bAllDirty = true;
- ((Component)this).invalidate();
- }
-
- }
-
- public Dimension preferredSize(int var1) {
- Dimension var2 = this.minimumSize(var1);
- Dimension var3 = ((Component)this).size();
- return new Dimension(Math.max(var2.width, var3.width), Math.max(var2.height, var3.height));
- }
-
- public Dimension preferredSize() {
- return this.rowsToShow > 0 ? this.preferredSize(this.rowsToShow) : this.preferredSize(this.items.size());
- }
-
- public Dimension minimumSize(int var1) {
- this.font = ((Component)this).getFont();
- if (this.font != null) {
- this.field_0 = ((Component)this).getFontMetrics(this.font);
- if (this.field_0 != null) {
- this.fontHeight = this.field_0.getHeight();
- if (this.bCellBorders) {
- this.cellHt = this.fontHeight + 5;
- } else {
- this.cellHt = this.fontHeight + 1;
- }
-
- return new Dimension(this.field_0.stringWidth("WN") * this.colsToShow / 2 + 6, var1 * this.cellHt + this.borderWidth + 4);
- }
- }
-
- return new Dimension(this.borderWidth + 6, this.borderWidth + 4);
- }
-
- public Dimension minimumSize() {
- return this.rowsToShow > 0 ? this.minimumSize(this.rowsToShow) : this.minimumSize(this.items.size());
- }
-
- public void addNotify() {
- super.addNotify();
- this.font = ((Component)this).getFont();
- this.field_0 = ((Component)this).getFontMetrics(this.font);
- this.fontHeight = this.field_0.getHeight();
- this.updateWidths(this.field_0);
- }
-
- public synchronized void setColumns(int var1) {
- if (this.colsToShow != var1) {
- this.colsToShow = var1;
- ((Component)this).invalidate();
- }
-
- }
-
- public synchronized void blockPaint(boolean var1) {
- this.bBlockPaint = var1;
- if (!this.bBlockPaint) {
- ((Component)this).repaint();
- }
-
- }
-
- public synchronized void setFont(Font var1) {
- if (var1 != null) {
- super.setFont(var1);
- this.field_0 = ((Component)this).getFontMetrics(var1);
- this.updateWidths(this.field_0);
- this.xCoord = 0;
- if (this.bOsFlag) {
- this.bAllDirty = true;
- ((Component)this).invalidate();
- }
-
- }
- }
-
- public synchronized void setListBoxFont(Font var1) {
- this.setFont(var1);
- }
-
- public synchronized Font getListBoxFont() {
- return super.getFont();
- }
-
- public synchronized void scrollVertical(int var1, boolean var2) {
- int var3 = this.nTopRow;
- if (this.visibleRows == 0) {
- var3 = 0;
- } else {
- if (var2) {
- var3 = var1;
- } else {
- switch (var1) {
- case 601:
- --var3;
- break;
- case 602:
- ++var3;
- break;
- case 603:
- var3 -= this.visibleRows;
- break;
- case 604:
- var3 += this.visibleRows;
- }
- }
-
- if (var3 < 0) {
- var3 = 0;
- } else if (var3 > this.items.size() - this.visibleRows) {
- var3 = this.items.size() - this.visibleRows;
- if (var3 < 0) {
- var3 = 0;
- }
- }
- }
-
- if (this.nTopRow != var3) {
- this.nTopRow = var3;
- this.VBar.setValue(var3);
- this.bAllDirty = true;
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
- }
-
- }
-
- public synchronized void scrollHorizontal(int var1, boolean var2) {
- int var3 = this.xCoord;
- if (var2) {
- var3 = -var1;
- } else {
- switch (var1) {
- case 601:
- ++var3;
- break;
- case 602:
- --var3;
- break;
- case 603:
- var3 += this.lWidth;
- break;
- case 604:
- var3 -= this.lWidth;
- }
- }
-
- if (var3 > 0) {
- var3 = 0;
- } else if (-var3 > this.HBar.getMaximum()) {
- var3 = -this.HBar.getMaximum();
- }
-
- if (this.xCoord != var3) {
- this.xCoord = var3;
- this.HBar.setValue(-var3);
- this.bAllDirty = true;
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
- }
-
- }
-
- public synchronized void update(Graphics var1) {
- if (!this.bBlockPaint && !this.bInternalBlockPaint) {
- this.paint(var1);
- }
-
- }
-
- public synchronized void paint(Graphics var1) {
- Rectangle var2 = var1.getClipRect();
- if (var2.x != 0 || var2.y != 0) {
- this.bAllDirty = true;
- if (this.bClipRectHack) {
- this.bClipRectHack = false;
- ((Component)this).repaint();
- return;
- }
- }
-
- this.bClipRectHack = false;
- int var9 = 0;
- int var10 = 0;
- byte var11 = 0;
- int var12 = 0;
- int var13 = 0;
- boolean var14 = false;
- boolean var15 = false;
- var2 = ((Component)this).bounds();
- this.font = var1.getFont();
- this.field_0 = var1.getFontMetrics(this.font);
- this.fontHeight = this.field_0.getHeight();
- this.fontDescent = this.field_0.getDescent();
- int var4 = this.items.size();
- if (this.bCellBorders) {
- this.cellHt = this.fontHeight + 5;
- } else {
- this.cellHt = this.fontHeight + 1;
- }
-
- if (var4 == 0) {
- this.nTopRow = 0;
- this.visibleRows = 0;
- var15 = false;
- var14 = false;
- this.xCoord = 0;
- } else {
- if (this.bAllowShowHBar && this.longestLineValue > var2.width - this.borderWidth) {
- var15 = true;
- var10 = this.barSize;
- } else {
- var15 = false;
- var10 = 0;
- }
-
- int var8 = (var2.height - var10 - this.borderWidth - 4) / this.cellHt;
- if (this.bAllowShowVBar && var4 > var8) {
- var14 = true;
- var9 = this.barSize;
- if (!var15 && this.bAllowShowHBar && this.longestLineValue > var2.width - this.borderWidth - var9) {
- var15 = true;
- var10 = this.barSize;
- var8 = (var2.height - var10 - this.borderWidth - 4) / this.cellHt;
- }
- } else {
- var14 = false;
- var9 = 0;
- }
-
- if (this.visibleRows != var8) {
- this.visibleRows = var8;
- this.bAllDirty = true;
- }
-
- if (var14) {
- this.VBar.reshape(var2.width - this.barSize - this.halfBorderWidth, this.halfBorderWidth, this.barSize, var2.height - this.borderWidth - var10);
- this.VBar.setValues(this.nTopRow, this.visibleRows, 0, var4 - this.visibleRows);
- this.VBar.setPageIncrement(this.visibleRows);
- this.lWidth = var2.width - var9 - this.borderWidth;
- if (!this.bVBarVisible) {
- this.bVBarVisible = true;
- this.VBar.show();
- }
- } else {
- this.lWidth = var2.width - this.borderWidth;
- if (this.bVBarVisible) {
- this.bVBarVisible = false;
- this.VBar.hide();
- }
- }
-
- if (var15) {
- this.HBar.reshape(this.halfBorderWidth, var2.height - this.barSize - this.halfBorderWidth, var2.width - this.borderWidth - var9, this.barSize);
- this.HBar.setValues(-this.xCoord, this.lWidth, 0, this.longestLineValue - this.lWidth);
- this.HBar.setPageIncrement(this.lWidth);
- if (!this.bHBarVisible) {
- this.bHBarVisible = true;
- this.HBar.show();
- }
- } else if (this.bHBarVisible) {
- this.bHBarVisible = false;
- this.HBar.hide();
- }
- }
-
- if (var4 == 0 || this.bAllDirty) {
- var1.clearRect(this.halfBorderWidth, this.halfBorderWidth, var2.width - this.borderWidth, var2.height - this.borderWidth);
- }
-
- if (this.borderType == 0) {
- var1.setColor(Color.black);
- var1.drawLine(0, 0, var2.width - 2, 0);
- var1.drawLine(0, 0, 0, var2.height - 2);
- var1.setColor(Color.gray);
- var1.drawLine(1, 1, var2.width - 3, 1);
- var1.drawLine(1, 1, 1, var2.height - 3);
- var1.setColor(Color.lightGray);
- var1.drawLine(1, var2.height - 2, var2.width - 2, var2.height - 2);
- var1.drawLine(var2.width - 2, 1, var2.width - 2, var2.height - 3);
- var1.setColor(Color.white);
- var1.drawLine(0, var2.height - 1, var2.width - 1, var2.height - 1);
- var1.drawLine(var2.width - 1, 0, var2.width - 1, var2.height - 1);
- }
-
- var1.clipRect(this.halfBorderWidth, this.halfBorderWidth, this.lWidth, var2.height - this.halfBorderWidth);
- if (this.nTopRow >= var4) {
- this.nTopRow -= this.visibleRows + 1;
- }
-
- int var6 = this.nTopRow;
- int var7 = Math.min(this.nTopRow + this.visibleRows, var4);
-
- for(int var16 = 0; var6 < var7; ++var16) {
- var12 = var16 * this.cellHt + this.yAdj;
- var13 = (var16 + 1) * this.cellHt + this.yAdj;
- ListItem var3 = (ListItem)this.items.elementAt(var6);
- if (var3.bDirty || this.bAllDirty) {
- var3.bDirty = false;
- var1.clearRect(this.halfBorderWidth, var12, this.lWidth, this.cellHt);
- }
-
- int var5;
- if (var3.image != null) {
- var5 = this.halfBorderWidth + 19 + 2;
- } else {
- var5 = this.halfBorderWidth;
- }
-
- if (var3.bCellBorder) {
- var11 = 2;
- } else {
- var11 = 0;
- }
-
- if (var3.bSelected) {
- var1.drawImage(this.SelectImage, this.xCoord + var5 + var11, var12, this.lWidth - this.xCoord, this.cellHt, this);
- var1.setColor(Color.white);
- } else if (var3.bEnabled) {
- if (var3.color == null) {
- var1.setColor(this.enabledColor);
- } else {
- var1.setColor(var3.color);
- }
- } else {
- var1.setColor(this.disabledColor);
- }
-
- var1.drawString(var3.sText, this.xCoord + var5 + var11, var13 - this.fontDescent);
- if (var3.image != null) {
- var1.drawImage(var3.image, this.xCoord + this.halfBorderWidth + var11 + 2, var12 + 2, 19, this.cellHt - 3, this);
- }
-
- if (var3.bCellBorder) {
- var1.setColor(var3.cellBorderColor);
- var1.drawRect(this.halfBorderWidth, var12, this.lWidth, this.cellHt);
- }
-
- ++var6;
- }
-
- this.extraPaint(var1, var2);
- this.bAllDirty = false;
- }
-
- public void extraPaint(Graphics var1, Rectangle var2) {
- }
-
- public synchronized void show() {
- this.bAllDirty = true;
- super.show();
- }
-
- public synchronized void reshape(int var1, int var2, int var3, int var4) {
- this.bAllDirty = true;
- this.bClipRectHack = true;
- super.reshape(var1, var2, var3, var4);
- }
-
- public synchronized void setDirty() {
- this.bAllDirty = true;
- }
-
- public boolean allSelected() {
- return this.countSelected == this.items.size();
- }
-
- public void setDirectNotify(boolean var1) {
- this.bDirectNotify = var1;
- }
-
- protected boolean validIndex(int var1) {
- return var1 >= 0 && var1 < this.items.size();
- }
-
- protected boolean isVisibleIndex(int var1) {
- return var1 >= this.nTopRow && var1 < this.nTopRow + this.visibleRows;
- }
-
- protected String paramString() {
- return super.paramString() + ", selected=" + this.getSelectedItem();
- }
-
- protected void shiftSelect(int var1, boolean var2) {
- int var3 = 0;
- int var4 = 0;
- if (this.lastSelected == -1) {
- this.select(var1);
- } else if (this.lastSelected == var1) {
- if (!var2) {
- this.bInternalBlockPaint = true;
- this.select(var1);
- this.bInternalBlockPaint = false;
- }
- } else if (this.lastSelected < var1) {
- if (!this.isEnabled(var1)) {
- return;
- }
-
- if (var2) {
- var3 = this.lastSelected + 1;
- var4 = Math.min(this.items.size(), var1 + 1);
- } else {
- var3 = 0;
- var4 = this.items.size();
- }
-
- for(; var3 < var4; ++var3) {
- ListItem var5 = (ListItem)this.items.elementAt(var3);
- if (var3 >= this.lastSelected && var3 <= var1) {
- if (!var5.bSelected) {
- var5.bDirty = true;
- var5.bSelected = true;
- ++this.countSelected;
- }
- } else if (var5.bSelected) {
- var5.bDirty = true;
- var5.bSelected = false;
- --this.countSelected;
- }
- }
- } else if (this.lastSelected > var1) {
- if (!this.isEnabled(var1)) {
- return;
- }
-
- if (var2) {
- var4 = Math.min(this.items.size(), this.lastSelected);
- } else {
- var3 = 0;
- var4 = this.items.size();
- }
-
- for(int var8 = 0; var8 < var4; ++var8) {
- ListItem var11 = (ListItem)this.items.elementAt(var8);
- if (var8 >= var1 && var8 <= this.lastSelected) {
- if (!var11.bSelected) {
- var11.bDirty = true;
- var11.bSelected = true;
- ++this.countSelected;
- }
- } else if (var11.bSelected) {
- var11.bDirty = true;
- var11.bSelected = false;
- --this.countSelected;
- }
- }
- }
-
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
-
- }
-
- protected void ctrlSelect(int var1) {
- ListItem var2 = (ListItem)this.items.elementAt(var1);
- if (var2.bEnabled) {
- if (var2.bSelected) {
- var2.bSelected = false;
- --this.countSelected;
- this.lastSelected = -1;
- } else {
- var2.bSelected = true;
- ++this.countSelected;
- this.lastSelected = var1;
- }
-
- var2.bDirty = true;
- if (!this.bInternalBlockPaint) {
- ((Component)this).repaint();
- }
-
- }
- }
-
- protected int mouseCalcIndex(int var1) {
- int var2;
- if (var1 < this.yAdj) {
- var2 = this.nTopRow - 1;
- } else {
- var2 = (var1 - this.yAdj) / this.cellHt + this.nTopRow;
- }
-
- if (var2 >= this.items.size()) {
- var2 = -1;
- } else if (var2 < 0) {
- var2 = 0;
- }
-
- return var2;
- }
-
- private void updateWidth(ListItem var1) {
- int var2 = var1.lineWidth + 6;
- if (var1.image != null) {
- var2 += 19;
- }
-
- if (var2 > this.longestLineValue) {
- this.longestLineValue = var2;
- }
-
- }
-
- private void updateWidths(FontMetrics var1) {
- this.longestLineValue = 0;
- int var2 = this.items.size();
- int var3 = 0;
-
- for(int var5 = 0; var5 < var2; ++var5) {
- ListItem var4 = (ListItem)this.items.elementAt(var5);
- var4.updateWidth(var1);
- var3 = var4.lineWidth + 6;
- if (var4.image != null) {
- var3 += 19;
- }
-
- if (var3 > this.longestLineValue) {
- this.longestLineValue = var3;
- }
- }
-
- }
-
- private void notifyParent(Event var1, int var2, boolean var3) {
- Object var4 = null;
- if (this.ilbParent != null) {
- var4 = this.ilbParent;
- } else if (this.bDirectNotify) {
- var4 = ((Component)this).getParent();
- }
-
- if (var4 == null) {
- var4 = this;
- }
-
- if (var3) {
- ((Component)var4).postEvent(new Event(this, var1.when, 1001, var1.x, var1.y, var1.key, this.lastDownModifiers, this.getSelectedItem()));
- } else {
- if (var1.x >= 0 && var1.x - this.xCoord < 19) {
- ListItem var5 = (ListItem)this.items.elementAt(var2);
- if (var5.image != null) {
- ((Component)var4).postEvent(new Event(this, var1.when, 16388, var1.x, var1.y, var1.key, this.lastDownModifiers, new Integer(var2)));
- }
- }
-
- ((Component)var4).postEvent(new Event(this, var1.when, 701, var1.x, var1.y, var1.key, this.lastDownModifiers, new Integer(var2)));
- }
- }
-
- private int keyCalcIndex(int var1, boolean var2) {
- if (var2) {
- this.lastIndex = var1;
- } else {
- this.lastIndex += var1;
- }
-
- if (this.lastIndex >= this.items.size()) {
- this.lastIndex = this.items.size() - 1;
- } else if (this.lastIndex < 0) {
- this.lastIndex = 0;
- }
-
- return this.lastIndex;
- }
- }
-